package ssm.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import ssm.dao.StudentMapper;
import ssm.entity.Classs;
import ssm.entity.Department;
import ssm.entity.Student;

@Service
public class StudentService {
	
	@Autowired
	private StudentMapper studentMapper;
	
	/**
	 * 判断是否有该学生账户
	 * @param record
	 * @return
	 */
	public boolean isStudentName(Student record) {
		if(studentMapper.getStudentByName(record) != null) {
			return true;
		}else {
			return false;
		}
		
	}
	
	/**
	 * 获取该学生信息
	 * @param record
	 * @return
	 */
	public Student getStudent(Student record) {
		
		return studentMapper.getStudent(record);
	}
	
	
	/**
	 * 获取某个班级的学生
	 * @param classsId
	 * @return
	 */
	public List<Student> getStudentsByClassId(Integer classsId){
		return studentMapper.getStudentsByClassId(classsId);
	}
	
	/**
	 * 获取某个院系的学生
	 * @param record
	 * @return
	 */
	public List<Student> getStudentsByDepartmentId(Integer record){
		return studentMapper.getStudentsByDepartmentId(record);
	}
	
	/**
	 * 获取所有学生
	 * @return
	 */
	public List<Student> getAllStudent(){
		
		return studentMapper.getAllStudent();
	}
	
	/**
	 * 分页获取学生
	 * @param record
	 * @return
	 */
	public List<Student> getStudentByPageNumber(Student record){
		return studentMapper.getStudentByPageNumber(record);
	}
	
	/**
	 * 修改学生信息
	 * @param record
	 * @return
	 */
	public int updateStudentSelective(Student record) {
		return studentMapper.updateStudentSelective(record);
	}
	
	/**
	 * 删除学生
	 * @param sId
	 * @return
	 */
	public int deleteStudent(Integer sId) {
		return studentMapper.deleteStudent(sId);
	}
	
	/**
	 * 重置学生密码
	 * @param sId
	 * @return
	 */
	public int resetStudentPassword(Integer sId) {
		return studentMapper.resetStudentPassword(sId);
	}
}
